/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Description: task下发，构造task逻辑信息
 * Author: zhaoandong
 * Create: 2023-02-08
 */

#include "task_logic_info.h"

namespace hccl {
TaskLogicInfo::TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType)
{
    taskLogicCmd.taskLogicType = taskLogicType;
    taskLogicCmd.index = index;
    taskFuncType = funcType;
}

TaskLogicInfo::TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType,
    std::vector<TxMemoryInfo> &txMems)
{
    taskLogicCmd.taskLogicType = taskLogicType;
    taskLogicCmd.index = index;
    taskFuncType = funcType;
    txAsync.txMems = txMems;
}

TaskLogicInfo::TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType,
    std::vector<RxMemoryInfo> &rxMems)
{
    taskLogicCmd.taskLogicType = taskLogicType;
    taskLogicCmd.index = index;
    taskFuncType = funcType;
    rxAsync.rxMems = rxMems;
}

TaskLogicInfo::TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType,
    void *signal, u32 userRank, u32 remoteUserRank, s32 stage)
{
    taskLogicCmd.taskLogicType = taskLogicType;
    taskLogicCmd.index = index;
    taskFuncType = funcType;
    taskLogicPara.dispatcherTaskLogicPara.signalWait.signal = signal;
    taskLogicPara.dispatcherTaskLogicPara.signalWait.userRank = userRank;
    taskLogicPara.dispatcherTaskLogicPara.signalWait.remoteRank = remoteUserRank;
    taskLogicPara.dispatcherTaskLogicPara.signalWait.stage = stage;
}

TaskLogicInfo::TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType,
    void *signal, u32 userRank, u64 offset, s32 stage)
{
    taskLogicCmd.taskLogicType = taskLogicType;
    taskLogicCmd.index = index;
    taskFuncType = funcType;
    taskLogicPara.dispatcherTaskLogicPara.signalRecord.signal = signal;
    taskLogicPara.dispatcherTaskLogicPara.signalRecord.userRank = userRank;
    taskLogicPara.dispatcherTaskLogicPara.signalRecord.offset = offset;
    taskLogicPara.dispatcherTaskLogicPara.signalRecord.stage = stage;
}

TaskLogicInfo::TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType, void *dst,
    uint64_t destMax, void *src, u64 count, HcclRtMemcpyKind kind)
{
    taskLogicCmd.index = index;
    taskLogicCmd.taskLogicType = taskLogicType;
    taskFuncType = funcType;
    taskLogicPara.dispatcherTaskLogicPara.memAsync.dst = dst;
    taskLogicPara.dispatcherTaskLogicPara.memAsync.destMax = destMax;
    taskLogicPara.dispatcherTaskLogicPara.memAsync.src = src;
    taskLogicPara.dispatcherTaskLogicPara.memAsync.count = count;
    taskLogicPara.dispatcherTaskLogicPara.memAsync.kind = kind;
}
}  // namespace hccl